home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / src / source.zoo / plstrl.c < prev    next >
C/C++ Source or Header  |  1989-05-15  |  1KB  |  48 lines

  1. /* Computes the length of a string in mm, including escape sequences  */
  2.  
  3. #include "plplot.h"
  4. #include <math.h>
  5.  
  6. float plstrl(string)
  7. char *string;
  8. {
  9.       int symbol[256];
  10.       short int xygrid[300];
  11.       int ch, i, length, level;
  12.       float width, xorg, dscale, scale, def, ht;
  13.       float xscl, xoff, yscl, yoff;
  14.  
  15.       width = 0.0;
  16.       gchr(&def,&ht);
  17.       dscale = 0.05*ht;
  18.       scale = dscale;
  19.       gmp(&xscl,&xoff,&yscl,&yoff);
  20.  
  21.       pldeco(symbol,&length,string);
  22.       xorg = 0.0;
  23.       level = 0;
  24.  
  25.       for (i=0; i<length; i++) {
  26.         ch = symbol[i];
  27.         if (ch == -1) {
  28.           level = level + 1;
  29.           scale = dscale * pow(0.75,(double)abs(level));
  30.         }
  31.         else if (ch == -2) {  
  32.           level = level - 1;
  33.           scale = dscale * pow(0.75,(double)abs(level));
  34.         }
  35.         else if (ch == -3) 
  36.           xorg = xorg - width * scale;
  37.         else if (ch == -4 || ch == -5) 
  38.           ;
  39.         else {
  40.           if (plcvec(ch,xygrid)) {
  41.             width = xygrid[4] - xygrid[3];
  42.             xorg = xorg + width*scale;
  43.           }
  44.         }
  45.       }
  46.       return(xorg);
  47. }
  48.